//
//  CLHCollectionViewVCViewModel.m
//  ListViewModel_Example
//
//  Created by 曹连华 on 2019/7/31.
//  Copyright © 2019 clh2046@163.com. All rights reserved.
//

#import "CLHCollectionViewVCViewModel.h"
#import "CLHCollectionCVCellModel.h"
@implementation CLHCollectionViewVCViewModel

-(void)resetDataSource {
    [self.dataSource resetSectionList:[self sections]];
    self.dataSource.sectionIndexTitles = @[@"A",@"B",@"C",@"D",@"E"];
}

- (NSArray <LVBaseCellSectionModel *> *)sections {
    
    NSMutableArray *arr = [NSMutableArray array];
    
    for (int i = 0 ; i < 5; i ++) {
        int arc = i%2;
        
        if (arc == 0) {
            LVBaseCellSectionModel *sectionModel = [[LVBaseCellSectionModel alloc]initWithRowList:[self row0s]];
            
            sectionModel.sectionHeader = [[LVBaseSectionHeaderFooterModel alloc]initWithReuseIdentifier:@"CLHCollectionSectionHeaderView" size:CGSizeMake([UIScreen mainScreen].bounds.size.width, 50)];
            sectionModel.sectionHeader.headerFooterTitle = [NSString stringWithFormat:@"section = %d 的 sectionHeaderView",i];

            sectionModel.sectionFooter = [[LVBaseSectionHeaderFooterModel alloc]initWithReuseIdentifier:@"CLHCollectionSectionFooterView" size:CGSizeMake([UIScreen mainScreen].bounds.size.width, 30)];
            sectionModel.sectionFooter.headerFooterTitle = [NSString stringWithFormat:@"section = %d 的 sectionFooterView",i];
            
            [arr addObject:sectionModel];
        } else {
            LVBaseCellSectionModel *sectionModel = [[LVBaseCellSectionModel alloc]initWithRowList:[self row1s]];
            sectionModel.minimumLineSpacing = 10;
            sectionModel.minimumInteritemSpacing = 5;
            sectionModel.sectionInset = UIEdgeInsetsMake(10, 5, 10, 5);
            
            sectionModel.sectionHeader = [[LVBaseSectionHeaderFooterModel alloc]initWithReuseIdentifier:@"CLHCollectionSectionHeaderView" size:CGSizeMake([UIScreen mainScreen].bounds.size.width, 50) ];
            sectionModel.sectionHeader.headerFooterTitle = [NSString stringWithFormat:@"section = %d 的 sectionHeaderView",i];
           
            sectionModel.sectionFooter = [[LVBaseSectionHeaderFooterModel alloc]initWithReuseIdentifier:@"CLHCollectionSectionFooterView" size:CGSizeMake([UIScreen mainScreen].bounds.size.width, 30) ];
            sectionModel.sectionFooter.headerFooterTitle = [NSString stringWithFormat:@"section = %d 的 sectionFooterView",i];
            
            [arr addObject:sectionModel];
        }
        
    }
    return arr;
}

- (NSArray <CLHCollectionCVCellModel *> *)row0s {
    NSMutableArray *arr = [NSMutableArray array];
    for (int i = 0; i < 5; i++) {
        CLHCollectionCVCellModel *row = [[CLHCollectionCVCellModel alloc]initWithCellClass:@"CLHCollectionViewCVCell"];
        row.mainTitle = [NSString stringWithFormat:@"row = %d",i];
        row.rowSize = CGSizeMake(([UIScreen mainScreen].bounds.size.width)/3, 200);
        
        if (i == 0) {
            row.canMove = YES;
        } else {
            row.canMove = YES;
        }
        [arr addObject:row];
    }
    return arr;
}

- (NSArray <CLHCollectionCVCellModel *> *)row1s {
    NSMutableArray *arr = [NSMutableArray array];
    for (int i = 0; i < 3; i++) {
        CLHCollectionCVCellModel *row = [[CLHCollectionCVCellModel alloc]initWithCellClass:@"CLHCollectionViewCVCell"];
        row.mainTitle = [NSString stringWithFormat:@"row = %d",i];
        row.rowSize = CGSizeMake(([UIScreen mainScreen].bounds.size.width)/3, 200);
        row.canMove = YES;
        [arr addObject:row];
    }
    return arr;
}
@end
